package comu.hnevc.zh.testdemo.fragment;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import comu.hnevc.zh.testdemo.MainActivity;
import comu.hnevc.zh.testdemo.R;

public class CarPeccancyImgFragment extends Fragment {
    private MainActivity activity;
    private TextView head_name;
    private Button return_btn;
    private ImageView pic1,pic2,pic3,pic4;

    public CarPeccancyImgFragment() {
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_car_peccancy_img,container,false);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        activity= (MainActivity) getActivity();
        head_name=activity.findViewById(R.id.header_title_tv);
        return_btn=activity.findViewById(R.id.id_btn_return);
        pic1=activity.findViewById(R.id.id_iv_pic1);
        pic2=activity.findViewById(R.id.id_iv_pic2);
        pic3=activity.findViewById(R.id.id_iv_pic3);
        pic4=activity.findViewById(R.id.id_iv_pic4);
        MybuttonListenet mybuttonListenet = new MybuttonListenet();

    }
    class MybuttonListenet implements View.OnClickListener{

        @Override
        public void onClick(View v) {
            PeccancyImgFragment fragment=new PeccancyImgFragment();
            Bundle bundle=new Bundle();
            switch (v.getId()){
                case R.id.id_iv_pic1:
                    bundle.putInt("i",1);
                    break;
                case R.id.id_iv_pic2:
                    bundle.putInt("i",2);
                    break;
                case R.id.id_iv_pic3:
                    bundle.putInt("i",3);
                    break;
                case  R.id.id_iv_pic4:
                    bundle.putInt("i",4);
                    break;
            }
            fragment.setArguments(bundle);
            getFragmentManager().beginTransaction()
                    .replace(R.id.id_content_view,fragment)
                    .commit();

        }
    }
}
